package com.emperor.category.app;

import java.util.Map;

import org.apache.log4j.Logger;

import com.emperor.core.app.App;
import com.emperor.core.app.AppConstant;
import com.emperor.core.app.AppCtrl;

public class CategoryAppCtrl implements AppCtrl {

	public static final String CATEGORY_CTRL = "category.ctrl";
	public static final String CATEGORY_NEW = "category.new";
	public static final String CATEGORY_MGM = "category.mgm";
	public static final String CATEGORY_DEL = "category.del";
	
	public static final String CATEGORY_MSG = "category.msg";
	public static final String CATEGORY_ID = "category.id";
	public static final String CATEGORY_TYPE = "category.type";
	
	public static Logger log = Logger.getLogger(CategoryAppCtrl.class);
	
	@Override
	public void doProcess(Map<String, Object> params) {
		App app = null;
		if (params == null) {
			log.error("Param is null");
		} else if (params.get(AppConstant.ACTION).equals(CATEGORY_MGM)) {
			app = new CategoryAppMgm(params);
		} else if (params.get(AppConstant.ACTION).equals(CATEGORY_DEL)) {
			app = new CategoryAppDel(params);
		} else {
			app = new CategoryAppNew(params);
		}
		
		
		if (app != null) {
			app.open();
		}
	}

}
